package main;

public class SquareRoot {
	private static final double EPSILON = .000001;

	public static double sqrt(double x) {
		double app = x;
		if (x < 0)
			throw new IllegalArgumentException();
		while (Math.abs(app*app-x) >= EPSILON)
			app -= (app*app - x) / 2 / app;
		return app;
	}
}
